package com.yhg.backend.websocket.pojo;

/**
 * 用来封装服务端给浏览器发送的消息数据
 */

public class ResultMessage {

    private boolean isSystem;
    private String fromName;
    private String toName; // 添加接收者字段
    private Object message;// 如果是系统消息是数组
    private long timestamp; // 添加时间戳字段

    public ResultMessage() {
        this.timestamp = System.currentTimeMillis();
    }

    public ResultMessage(boolean isSystem, String fromName, Object message) {
        this.isSystem = isSystem;
        this.fromName = fromName;
        this.message = message;
        this.timestamp = System.currentTimeMillis();
    }
    
    public ResultMessage(boolean isSystem, String fromName, String toName, Object message) {
        this.isSystem = isSystem;
        this.fromName = fromName;
        this.toName = toName;
        this.message = message;
        this.timestamp = System.currentTimeMillis();
    }

    public boolean isSystem() {
        return isSystem;
    }

    public void setSystem(boolean system) {
        isSystem = system;
    }

    public String getFromName() {
        return fromName;
    }

    public void setFromName(String fromName) {
        this.fromName = fromName;
    }

    public Object getMessage() {
        return message;
    }

    public void setMessage(Object message) {
        this.message = message;
    }
    
    public String getToName() {
        return toName;
    }

    public void setToName(String toName) {
        this.toName = toName;
    }
    
    public long getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(long timestamp) {
        this.timestamp = timestamp;
    }

    @Override
    public String toString() {
        return "ResultMessage{" +
                "isSystem=" + isSystem +
                ", fromName='" + fromName + '\'' +
                ", message=" + message +
                '}';
    }

}
